package com.teachoa.web;

import com.teachoa.bean.User;
import com.teachoa.util.MD5Util;

public class IndexController extends BaseController {
	
	public void index() {
		renderJsp("/login.jsp");
	}
	
	public void login() {
		String username = getPara("username");
		String password = MD5Util.md5(getPara("password"));
		User user = User.dao.checkUser(username, password);
		if(user==null) 
			renderJson(fail("用户名或密码错误！！"));
		else {
			setSessionAttr("user", user);
			renderJson(success(null));
		}
	}
	
	public void logout() {
		removeSessionAttr("user");
		redirect("/");
	}

}
